package org.kzwl.book.controller.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.kzwl.comm.advice.Consts;
import org.kzwl.comm.pojo.ResponseData;
import org.kzwl.comm.pojo.bo.QueryAdminCuVenuesBO;
import org.kzwl.comm.pojo.bo.SaveCuVenuesBO;
import org.kzwl.comm.pojo.bo.venues.QueryDetailsBO;
import org.kzwl.comm.pojo.bo.venues.VenueBasicBO;
import org.kzwl.comm.pojo.dto.venues.VenuesBasicDTO;
import org.kzwl.comm.pojo.dto.venues.VenuesDetailsDTO;
import org.kzwl.comm.utils.MyUtils;
import org.kzwl.entity.web.CuVenues;
import org.kzwl.service.web.CuVenuesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 场馆预约 前端控制器
 * </p>
 *
 * @author 张国伟/郭家恒
 * @since 2020-12-18
 */
@Api("活动预约")
@RestController
@RequestMapping("/cu-venues")
public class CuVenuesController {

    @Autowired
    CuVenuesService cuVenuesService;

    @PostMapping("/saveOne")
    public ResponseData<Void> saveOne(@RequestBody @Valid SaveCuVenuesBO saveCuVenuesBO)
    {
        return cuVenuesService.saveOne(saveCuVenuesBO);
    }


    @PostMapping("/queryPages")
    public ResponseData<IPage<CuVenues>> queryPages(@RequestBody QueryAdminCuVenuesBO queryAdminCuVenuesBO)
    {
        return cuVenuesService.queryPages(queryAdminCuVenuesBO);
    }

    @PostMapping("/queryOne")
    public ResponseData<CuVenues> queryOne(@RequestBody Long Id)
    {
        return cuVenuesService.queryOne(Id);
    }

    @PostMapping("/updateOne")
    public ResponseData<Void> updateOne(@RequestBody SaveCuVenuesBO saveCuVenuesBO)
    {
        return cuVenuesService.updateOne(saveCuVenuesBO);
    }

    @PostMapping("/deleteId")
    public ResponseData<Void> deleteId(@RequestBody Long Id)
    {
        return cuVenuesService.deleteId(Id);
    }

    @ApiOperation(value = "场馆预约基础查询")
    @PostMapping("/queryBasic")
    public ResponseData<IPage<VenuesBasicDTO>> queryBasic(@RequestBody VenueBasicBO bo)
    {
        IPage<VenuesBasicDTO> page = cuVenuesService.queryBasic(bo);;
        return new ResponseData<>(page);
    }

    @ApiOperation(value = "查询场馆预约详细",notes = "cuUserId(用户编号)-可选，当前用户未登录不填 cuVenuesId(活动id)--必填")
    @PostMapping("/queryDetails")
    public ResponseData<VenuesDetailsDTO> queryDetails(@RequestBody QueryDetailsBO bo)
    {
        VenuesDetailsDTO dto = cuVenuesService.queryDetails(bo);;
        return new ResponseData<>(dto);
    }

    @ApiOperation(value = "参与场馆预约")
    @PostMapping("/joinVenues")
    public ResponseData<Void> joinVenues(@RequestBody QueryDetailsBO bo)
    {
        cuVenuesService.joinVenues(bo);;
        return new ResponseData<>();
    }
}
